import 'dart:io';

void main() {
  final pubspec = File('pubspec.yaml').readAsStringSync();
  final version = RegExp(r'version:\s*([^\n]+)').firstMatch(pubspec)?.group(1);
  
  File('lib/app_version.dart').writeAsStringSync('''
/*由scripts/version_generator.dar 执行自动生成*/
// 请不要手动修改该文件

class AppVersion {
  static const String version = '$version';
    static String get versionName => AppVersion.version.split('+')[0];
  
  static int get buildNumber => int.tryParse(AppVersion.version.split('+')[1]) ?? 0;
}
''');
}